package LeetCode;

public class LC_299_BullsandCows {

    public static void main(String[] args) {

    }

    class Solution {
        public String getHint(String secret, String guess) {
            int len = secret.length();

            int A = 0;
            int B = 0;
            int count[] = new int[10];

            for (int i = 0; i < len; i++) {
                int s = secret.charAt(i) - '0';
                int g = guess.charAt(i) - '0';
                if (s == g)
                    A++;
                else {
                    if (count[g] > 0) B++;
                    if (count[s] < 0) B++;
                    count[g]--;
                    count[s]++;
                }
            }
            return A + "A" + B + "B";
        }

    }
}